//初始数组和中奖人员
let arr = ['1', '2', '3', '4', '5', '6', '7', '8'];
let luck;

//获取html元素
let one = document.querySelector('#one');
let two = document.querySelector('#two');
let three = document.querySelector('#three');

let a = document.querySelector('#a');
let b = document.querySelector('#b');
let c = document.querySelector('#c');
//设置抽奖函数
function draw() {
  //随机抽奖的随机
  let num = Math.floor(Math.random() * arr.length);
  //将数组中的随机数赋予进对应的位置
  luck = arr.splice(num, 1);

  if (this === a) {
    one.textContent = luck;
    a.disabled = true;
  } else if (this === b) {
    two.textContent = luck;
    b.disabled = true;
  } else if (this === c) {
    three.textContent = luck;
    c.disabled = true;
  }
}


//设置点击事件
a.addEventListener('click', draw);
b.addEventListener('click', draw);
c.addEventListener('click', draw);